/**
 * 
 */
package controller.member;

import model.MUser;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import common.interf.IErrorHandle;

import service.interf.IUser;

/**
 * @author 鄢倩
 * 2012-12-8
 */
@Controller
@RequestMapping("/user")
public class MemberFindController {

	@Autowired
	IUser user;
	@Autowired
	private IErrorHandle errorHandle;
	
	@RequestMapping("/find_all_users.htm")
	@ResponseBody
	public String findAllUsers() {
		String s = "";
		try {
			s = user.findAll(0, 0);
			System.out.println(s);
		} catch (Exception e) {
			System.out.println("methods : findAllUsers exception");
			errorHandle.handleErr(e);
		}
		return s;
	}
	
	@RequestMapping("/find_userById.htm")
	@ResponseBody
	public String findUserById(MUser model){
		String s = "";
		try {
			s = user.findUserById(model.getUserId());
		} catch (Exception e) {
			System.out.println("method : findUserById exception");
			errorHandle.handleErr(e);
		}
		return s;		
	}

	@RequestMapping("/find_userByName.htm")
	@ResponseBody
	public String findUserByUserName(MUser model){
		String s = "";
		try {
			s = user.findUserByUserName(model.getUserName());
		} catch (Exception e) {
			System.out.println("method : findUserById exception");
			errorHandle.handleErr(e);
		}
		return s;		
	}

	
	
	
}
